<!-- 每日体检 -->
<template>
	<view>
		<view class="tops dis dis1">
			<image :src="tisipng" mode="aspectFit" class="tisi"></image>
		</view>
		<view class="dis dis6">
			<block v-for="(item,index) in list" :key="index">
				<view class="items dis dis5 dis1 dis2" @click="goUrl(item.id,item.title)">
					<image :src="item.pic" mode="aspectFit" class="imgs"></image>
					<image src="../../../static/image/i_8.png" mode="aspectFit" class="imagus" v-if="item.isupdate==1"></image>
					<text class="texts">{{item.title}}</text>
				</view>
			</block>
		</view>
		<view class="kongs"></view>
		<view class="btn dis dis3 dis2" v-if="!isShows">
			<view class="eliminate contenr" @click="eliminate">清除重测</view>
			<view class="btns contenr">提交标签</view>
		</view>
		<view class="btn dis dis3 dis2" v-if="isShows">
			<view class="eliminate eliminate_1 contenr" @click="eliminate">清除重测</view>
			<view class="btns btns_1 contenr" @click="goUrls(0)">提交标签</view>
		</view>
		<view class="activeEstop contenr" catchtouchmove="preventD" v-if="is">
			<view class="estop dis dis5 dis1 dis2">
				<view class="topTexts dis dis1">
					<text class="text">清除重测</text>
				</view>
				<view class="topTexts topTexts_1  dis dis1">
					<text class="text">清除所选症状标签后，可重新测评。</text>
				</view>
				<view class="btnsEstop dis">
					<view class="bnt_1s contenr" @click="showIs">取消</view>
					<view class="bnt_1s bnt_1s_2 contenr" @click="eliminateIs">确认</view>
				</view>
			</view>
		</view>

		<!-- 1.2版本新增   -->
		<view class="new1_2 contenr" v-if="isUser">
			<view class="new1_2_bg">
				<view class="kongs_1"></view>
				<view class="tops_1 contenr">健康档案</view>
				<view class="alin">
					<view class="alin_12 dis dis3 dis_1">
						<text class="name_12 padds">昵称</text>
						<text class="name_1_2 padds">{{nickName}}</text>
					</view>
					<view class="alin_12 dis dis3 dis_1 alin_1_2">
						<text class="name_12 padds">性别</text>
						<text class="name_1_2 padds">{{sex==1?'男':'女'}}</text>
					</view>
					<view class="alin_12 dis dis3 dis_1 alin_1_2">
						<text class="name_12 padds">年龄</text>
						<view class="alinitem">
							<picker @change="getAge" mode="date" :value="startDate" :end="endDate">
								<view class="itemLeft dis dis2 dis7  " v-if="age==-1">请选择</view>
								<view class="itemLeft dis dis2 dis7 name_1_2_12" v-if="age !=-1">{{age}}岁</view>
							</picker>
						</view>
					</view>
					<view class="alin_12 dis dis3 dis_1 alin_1_2">
						<text class="name_12 padds">出生地</text>
						<view class="alinitem">
							<pickerList :city_s="city" :index='indexs' :multiIndex="multiIndex" :multiArray="multiArray" :objectMultiArray1="objectMultiArray1" @fnnc="getCtiy1"></pickerList>
						</view>
					</view>
					<view class="alin_12 dis dis3 dis_1 alin_1_2">
						<text class="name_12 padds">常居地</text>
						<view class="alinitem">
							<pickerList :city_s="city1"  :index='indexs1' :multiIndex="multiIndex" :multiArray="multiArray" :objectMultiArray1="objectMultiArray1" @fnncs="getCtiy2"></pickerList>
						</view>
					</view>
				</view>
				<view class="btons_1 contenr" v-if="!isBtn">确认</view>
				<view class="btons_1 contenr btons_2" v-if="isBtn" @click="subtimUser">确认</view>
				<view class="imageTou">
					<image :src="imageUrl" mode="scaleToFill" class="imgs"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	let app = getApp().globalData;
	import config from '@/common/js/config.js';
	import util from '@/common/js/util.js';
	import index from '@/common/js/city.js';
	import index1 from '@/common/js/city.js';
	import pickerList from '@/components/pickerst.vue';
	export default {
		components:{
			pickerList
		},
		data() {
			return {
				list: [],
				isShows: false,
				is: false,
				tisipng: `${config.imgUrl}tisi.png`,
				endDate: '1995-06-15',
				startDate: '1995-06-15',
				age: -1,
				ageDate: '', //出生日期
				// region: ['广东省', '深圳市', '海珠区'],
				// region1: ['广东省', '深圳市', '海珠区'],
				city: '', //出生地
				birthprovince:'',
				city1: '', //长居地
				province:'',
				isBtn: false,
				isUser: false, //是否填写资料
				sex: '', //性别
				nickName: '',
				imageUrl: '',
				//
				multiIndex: [0, 0],
				multiArray: index.multiArray,
				objectMultiArray: index.objectMultiArray,
				multiIndex1: [1, 1],
				multiArray1:index1.multiArray,
				objectMultiArray1: index1.objectMultiArray,
				indexs:1,
				indexs1:2,
				
			};
		},
		methods: {
			// 选择症状
			goUrl(list, name) {
				// console.log(list)
				// app.optionGroupInfoList = list;
				uni.navigateTo({
					url: `../face/face?title=${name}&id=${list}`
				})
			},
			// 生成报告
			goUrls(id) {
				let that = this;
				// if(id==0){
				// 	// 判断用户是否生成过报告

				// 		uni.navigateTo({
				// 			url:'../generate/generate'
				// 		})
				// 	}
				// 	return
				// }
				uni.navigateTo({
					url: '../generate/generate'
				})
				// that.is = false
			},
			getTestpaper() {
				let that = this;
				this.$http._post('examination/index.do').then(res => {
					if (res.data.issuccess == 0) {
						that.$http.isMssage(res.data.msg);
						return;
					}
					let is = false;
					let {
						data
					} = res.data;
					for (let i = 0; i < data.length; i++) {
						if (data[i].isupdate == 1) {
							is = true;
						}
					}
					that.isShows = is;
					that.list = data;
					console.log(data)
				})
			},
			preventD() {
				return
			},
			amendIs() {
				this.is = false
			},
			// 清除标签选择
			eliminate() {
				this.is = true;
			},
			showIs() {
				this.is = false;
			},
			eliminateIs() {
				let _this = this;
				this.$http._post('examination/clearselect.do').then(res => {
					if (res.data.issuccess == 1) {
						// _this.$http.isMssage('清除成功');
						_this.is = false;
						_this.getTestpaper();
					}
					console.log(res)
				})
			},
			// 版本1.2
			getAge(e) {
				let data = new Date(e.detail.value).getTime();
				let date = new Date().getTime();
				let ages = parseInt((date - data) / (24 * 60 * 60 * 1000 * 365));
				this.age = ages;
				this.ageDate = e.detail.value;
				console.log('data', data)
				console.log('date', date)
				console.log('ages', ages)
				this.isBtnFun()
			},
			isBtnFun() {
				let age = this.age;
				let city = this.city;
				let city1 = this.city1;
				console.log('city1',city1)
				console.log('city',city)
				console.log('age',age)
				if (age != -1 && city != '' && city1 != '') {
					this.isBtn = true
				}
			},
			isUserlogin() {
				console.log(app)
				let that = this;
				let userInfo = uni.getStorageSync('userInfo')
				console.log('that.isUser', uni.getStorageSync('isUser'))
				if (uni.getStorageSync('isUser') == '上传成功') {
					that.isUser = false;
					return
				}
				console.log('userInfo', userInfo)
				if (app.user.sex) {
					if (app.user.city == "" || app.user.birthcity == '' || app.user.age == -1) {
						that.isUser = true;
					}
					if (userInfo.nickName.length > 8) {
						userInfo.nickName = userInfo.nickName.substr(0, 8)
					}
					that.nickName = app.user.nickname;
					that.imageUrl = app.user.avatarurl;
					that.city = app.user.birthcity;
					that.city1 = app.user.city;
					that.sex = app.user.sex;
					if (app.user.birth) {
						let data = new Date(app.user.birth).getTime();
						let date = new Date().getTime();
						let ages = parseInt((date - data) / (24 * 60 * 60 * 1000 * 365));
						that.age = ages;
					}
					console.log('sssss')
				} else {
					console.log('难搞哦')
					this.sex = app.user.sex || userInfo.gender;
					this.isUser = true;
					if (userInfo.nickName.length > 8) {
						userInfo.nickName = userInfo.nickName.substr(0, 8)
					}
					this.nickName = app.user.nickname || userInfo.nickName;
					this.imageUrl = app.user.avatarurl || userInfo.avatarUrl;
					this.city = app.user.birthcity;
					this.city1 = app.user.city;
					if (app.user.birth) {
						let data = new Date(app.user.birth).getTime();
						let date = new Date().getTime();
						let ages = parseInt((date - data) / (24 * 60 * 60 * 1000 * 365));
						that.age = ages;
					}
				}
			},
			subtimUser() {
				let that = this;
				let province = app.user.province || this.province; //常住地省会
				let city = app.user.city || this.city1; //常住地城市
				let birthprovince = app.user.birthprovince || this.birthprovince; //出生地省会
				let birthcity = app.user.birthcity || this.city //  出生地城市
				let birthday = app.user.birth || this.ageDate; //生日 
				console.log('常住地省会', province)
				console.log('常住地城市', city)
				console.log('出生地省会', birthprovince)
				console.log('出生地城市', birthcity)
				console.log('生日', birthday)
				this.$http._post('user/setcityinfo.do', {
					province,
					city,
					birthprovince,
					birthcity,
					birthday
				}).then(res => {
					console.log(res)
					if (res.data.issuccess == 0) {
						that.$http.isMssage(res.data.msg);
						return;
					}
					that.isUser = false;
					uni.setStorageSync('isUser', '上传成功')
				})

			},
			getCtiy1(data){
				console.log(data)
				this.birthprovince = data.province;
				this.city = data.city;
				this.isBtnFun()
			},
			getCtiy2(data){
				console.log(data)
				this.province = data.province;
				this.city1 = data.city;
				this.isBtnFun()
			}
			
		},
		onLoad(e) {
			this.isUserlogin();
			let date = new Date();
			let endDate = util.fmdata(date);
			this.endDate = `${endDate.Y}-${endDate.M}-${endDate.D}`;
		},
		onShow() {
			this.getTestpaper();
		},

	}
</script>

<style lang="scss" scoped>
	@import "../../../common/css/flex.css";
	@import "../../../common/css/index.scss";

	.tops {
		width: 100%;
		height: 120upx;

		// border: 1px solid red;
		.tisi {
			margin-top: 16upx;
			width: 666upx;
			height: 98upx;
		}
	}

	.items {
		width: 312upx;
		height: 270upx;
		background: #FFFFFF;
		border-radius: 24upx;
		margin: 32upx 0upx 0 42upx;
		position: relative;

		.imgs {
			width: 128upx;
			height: 128upx;
		}

		.texts {
			font-size: 32upx;
			font-family: $typeface;
			font-weight: 500;
			color: #333333;
			margin-top: 33upx;
		}
	}

	.imagus {
		width: 88upx;
		height: 40upx;
		position: absolute;
		top: 21upx;
		right: 0upx;
	}

	.kongs {
		width: 100%;
		height: 140upx;
	}

	.btn {
		width: 750upx;
		height: 128upx;
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		border-top: 0.5px solid #e8e8e8;

		.eliminate {
			width: 228upx;
			height: 88upx;
			background: #333;
			border-radius: 44upx;
			font-size: 32upx;
			font-family: $typeface;
			font-weight: 500;
			color: #fff;
			margin-left: 32upx;
		}

		.btns {
			width: 426upx;
			height: 88upx;
			background: #C1C1C1;
			border-radius: 44upx;
			margin-right: 32upx;
			font-size: 32upx;
			font-family: $typeface;
			font-weight: 500;
			color: #FFFFFF;
		}

		.activeBtn {
			background-color: #FFD344;
			color: #333;
		}

		.btns_1 {
			background-color: #FFD344;
			color: #333333;
		}
	}

	.activeEstop {
		width: 750upx;
		height: 100%;
		background: rgba(0, 0, 0, 0.6);
		overflow: hidden;
		position: fixed;
		bottom: 0;
		z-index: 99;

		.estop {
			width: 640upx;
			height: 402upx;
			background: #FFFFFF;
			border-radius: 24upx;

			.topTexts {
				width: 544upx;
				height: 50upx;
				margin-top: 64upx;
				font-size: 36upx;
				font-family: $typeface;
				font-weight: 500;
				color: #000000;

				.text {}
			}

			.topTexts_1 {
				margin-top: 48upx;
				font-size: 32upx;
				font-family: $typeface1;
				font-weight: 400;
				color: #666;
			}

			.btnsEstop {
				width: 100%;
				height: 128upx;
				margin-top: 48upx;

				.bnt_1s {
					width: 240upx;
					height: 80upx;
					background: #EDEDED;
					border-radius: 40upx;
					font-size: 30upx;
					font-family: $typeface;
					font-weight: 500;
					color: #333333;
					margin-left: 56upx;
					// margin-right: 48rpx;
				}

				.bnt_1s_2 {
					background-color: #FFD344;
					font-size: 30upx;
					font-weight: 500;
					color: #333333;
					margin-right: 56upx;
					margin-left: 48rpx;
				}

				.tuchbtn {
					width: 264upx;
					height: 88upx;

				}
			}
		}
	}

	/**
	 * 1.2版本新增
	 */
	.new1_2 {
		width: 750upx;
		height: 100%;
		background: rgba(0, 0, 0, .6);
		// opacity: 0.6;
		position: fixed;
		z-index: 99;
		bottom: 0;

		.new1_2_bg {
			width: 640upx;
			height: 960upx;
			background: #FFFFFF;
			border-radius: 24upx;
			position: relative;
			.kongs_1 {
				width: 100%;
				height: 1upx;
			}

			.tops_1 {
				width: 100%;
				height: 50upx;
				font-size: 36upx;
				font-family: $typeface;
				font-weight: 500;
				color: #000000;
				margin-top: 48upx;
			}

			.alin {
				margin: auto;
				width: 584upx;
				min-height: 156upx;
				background: linear-gradient(180deg, #F8F8F8 0%, #FFFFFF 100%);
				border-radius: 8upx 8upx 0px 0px;
				margin-top: 97upx;

				.alin_12 {
					width: 520upx;
					height: 156upx;
					margin: auto;
					border-bottom: 1upx solid #EBEBEB;

					.padds {
						margin-bottom: 16upx;
					}

					.name_12 {
						font-size: 30upx;
						font-family: $typeface;
						font-weight: 500;
						color: #000000;
					}

					.name_1_2 {
						font-size: 30upx;
						font-family: $typeface1;
						font-weight: 400;
						color: #999999;
					}

					.alinitem {
						width: 120upx;
						height: 80%;

						// border: 1px solid red;
						picker,
						.itemLeft {
							width: 100%;
							height: 80upx;
							font-size: 30upx;
							font-family: $typeface1;
							font-weight: 400;
							color: #6E9DFF;
						}

						.name_1_2_12 {
							color: #999999;
						}
					}
				}

				.alin_1_2 {
					height: 106upx;
				}
			}

			.btons_1 {
				width: 240upx;
				height: 80upx;
				background: #C1C1C1;
				border-radius: 40upx;
				margin: auto;
				margin-top: 50upx;
				font-size: 30upx;
				font-family: $typeface;
				font-weight: 500;
				color: #FFFFFF;
			}

			.btons_2 {
				color: #333333;
				background: #FFD344;
			}

			.imageTou {
				width: 124upx;
				height: 124upx;
				position: absolute;
				top: 115upx;
				left: 255upx;
				// border: 1px solid red;
				border-radius: 50%;
				.imgs {
					width: 124upx;
					height: 124upx;
					border-radius: 50%;
				}
			}
		}
	}
</style>
